<?php

namespace Framework\auth;
use Framework\auth\bean\RedisConfigBean;

/**
 * Class RedisInstance
 * @package Framework\auth
 * @author 飞鸟和鱼
 */
class RedisInstance
{
    /**
     * @var \Redis
     */
    private static $instance;

    /**
     * @return mixed
     */
    public static function getInstance(RedisConfigBean $bean)
    {
        if (!self::$instance){
            self::$instance = new \Redis();
            self::$instance->connect($bean->getHost(), $bean->getProt(), $bean->getTimeout());
            if (!empty($bean->getPass())){
                self::$instance->auth($bean->getPass() );
            }
        }
        return self::$instance;
    }
}